<?php
namespace My\Controller;

use Utuo\BackgroundController;

class DistributionShopArticleController extends BackgroundController {
    
	public function _initialize() {
		$this->setControllerTitle("文章管理");
		$this->setActionTitle(array(
				'index' => "文章列表",
				'modify' => "编辑文章",
				'add' => "添加文章",
				'recycle' => "回收站"
		));
		$this->setActionNav('index,add,recycle');
		$this->assign("sid", $this->aid);
	}
	
	public function getLists( $is_deleted ) {
		$page = $this->getPage ();
		$pagesize = $this->getPageSize ();
		$d = D ( 'DistributionShopArticle' );
		$condition = array (
			'cid' => $this->aid,
			'is_deleted' => $is_deleted,
		);
		$articleLists = $d->where ( $condition )->limit ( $pagesize )->page ( $page )->order ( 'id DESC' )->select ();
		$goodsCount = $d->where ( $condition )->count ();
		foreach ( $articleLists as $k => &$v ) {
			$v['articleUrl'] = uu($this->aid, 'Home', 'DisShopArticle', 'show', "sid={$this->aid}&id={$v['id']}", true);
		}
		$this->assign ( 'distributionShopArticleLists', $articleLists );
		$this->showPage ( $goodsCount, $pagesize );
		$this->display();
	}
	
	
	/**
	 * 添加页
	 */
	public function addAction() {
	    $this->assign("cid", $this->aid);
		$this->display('save');
	}
	
	/**
	 * 修改页
	 */
	public function modifyAction() {
	    $this->assign("cid", $this->aid);
		$model = CONTROLLER_NAME;
		$config = D($model)->getOneById();
		$this->assign(lcfirst($model), $config);
		$this->display("save");
	}
	
	public function saveAction(){
	    parent::saveAction();
	}
	
}
